package com.cyh.testdesignpattern.iterator;

import java.util.Iterator;

//计算机系迭代器
public class ComputerCollegeIterator implements Iterator {

    //我们需要知道是用哪种方式存放的
    TDepartment[] tDepartments;
    int position = 0;

    public ComputerCollegeIterator(TDepartment[] tDepartments) {
        this.tDepartments = tDepartments;
    }

    @Override
    public boolean hasNext() {
        if(position >= tDepartments.length || tDepartments[position] == null) {
            return false;
        } else {
            return true;
        }
    }

    @Override
    public Object next() {
        TDepartment tDepartment = tDepartments[position];
        position += 1;
        return tDepartment;
    }

    @Override
    public void remove() {

    }
}
